package cn.wgd.zmx.controller;

import cn.wgd.zmx.domain.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@Controller
@Api("登录控制器")
public class LoginController {

    @Autowired
    @ApiModelProperty("注入session")
    private HttpSession httpSession;

<<<<<<< HEAD
    @RequestMapping(value = "/user_login", method = RequestMethod.POST)
    @ApiOperation(value = "登录")
    @ApiImplicitParam(name = "user", value = "用户", required = true, dataType = "User")
    public String login(User user) {
        /**
         * 保存用户信息到session里面
         */
        httpSession.setAttribute("userinfo", user);

        /**
         * 设置session失效时间，我这里设置为30s
         */
        httpSession.setMaxInactiveInterval(30 * 69);
=======
    @RequestMapping(value = "/user_login",method = RequestMethod.POST)
    @ApiOperation(value = "登录")
    @ApiImplicitParam(name = "user", value = "用户", required = true, dataType = "User")
    public String login(User user){
        /**
         * 保存用户信息到session里面
         */
        httpSession.setAttribute("userinfo",user);
>>>>>>> 6d085ac650d1276c28ed128411d02424e862f186

        /**
         * 通过用户名去数据库里面查
         */
        return "index";
    }
}
